{-# OPTIONS -Wall #-}

--------------------------------------------------------------------------------
-- |
-- Module      :  WumpusExpr.Operators
-- Copyright   :  (c) Stephen Tetley 2012
-- License     :  BSD3
--
-- Maintainer  :  stephen.tetley@gmail.com
-- Stability   :  unstable
-- Portability :  GHC (MPTC and more)
--
-- Relational operators are shared by different \"languages\"
-- (i.e. Expression algebraic types).
--
--------------------------------------------------------------------------------

module WumpusExpr.Operators
  (

    UnaryOp(..)    
  , BinOp(..)
  , RelOp(..)


  , unaryDocE
  , binDocE
  , relDocE


  ) where

import WumpusExpr.Utils

import Text.PrettyExprHPJ                   -- package: pretty-expr-hpj
import Text.PrettyExprHPJ.Haskell98


data UnaryOp = NEG | BNOT
  deriving (Eq,Show)


data BinOp = ADD | SUB | MUL | DIV | LOG_AND | LOG_OR | MOD
  deriving (Enum,Eq,Ord,Show)

data RelOp = EQU | NOT_EQU | LTHAN | GTHAN | LT_EQU | GT_EQU
  deriving (Enum,Eq,Ord,Show)




unaryDocE :: UnaryOp -> DocE -> DocE
unaryDocE NEG   = negateU
unaryDocE BNOT  = bitwiseNotU

binDocE :: BinOp -> DocE -> DocE -> DocE
binDocE ADD         = addB
binDocE SUB         = subtractB
binDocE MUL         = multiplyB
binDocE DIV         = divideB
binDocE LOG_AND     = logicalAndB
binDocE LOG_OR      = logicalOrB
binDocE MOD         = modB


relDocE :: RelOp -> DocE -> DocE -> DocE
relDocE EQU         = equalB
relDocE NOT_EQU     = notEqualB
relDocE LTHAN       = lessThanB
relDocE GTHAN       = greaterThanB
relDocE LT_EQU      = lessThanEqB
relDocE GT_EQU      = greaterThanEqB




